﻿using System;
using System.Data;
using Ue.Framework.Data;
using Ue.Infrastructure.EntityFactoryFramework;
using Ue.Qcdz.Domain;
using Ue.Qcdz.Domain.FriendLink;

namespace Ue.Qcdz.Repositories.FriendLink
{
    internal class FriendLinkFactory : IEntityFactory<FriendLinks>
    {
        #region Implementation of IEntityFactory<FriendLinks>

        internal class FieldNames : FieldNamesBase
        {
            public const string LinkName = "LinkName";
            public const string LinkUrl = "LinkUrl";
            public const string Remark = "Remark";
            public const string Status = "Status";
        }

        public FriendLinks BuildEntity(IDataReader reader)
        {
            return new FriendLinksProxy(
                reader.Get<string>(FieldNames.LinkName),
                reader.Get<string>(FieldNames.LinkUrl),
                reader.Get<string>(FieldNames.Remark),
                reader.Get<FriendListEnum>(FieldNames.Status),
                reader.Get<Guid>(FieldNames.EntityKey)
                );
        }

        #endregion
    }
}
